package com.ssy.lingxi.report.serviceimpl.tally;

import cn.hutool.core.collection.CollectionUtil;
import com.ssy.lingxi.common.constant.member.MemberRoleEnum;
import com.ssy.lingxi.report.api.enums.*;
import com.ssy.lingxi.report.api.vo.request.OperateNoticeVO;
import com.ssy.lingxi.report.dao.purchase.*;
import com.ssy.lingxi.report.entity.report.MemberTallyReportDO;
import com.ssy.lingxi.report.model.bo.MemberTallyReportBO;
import com.ssy.lingxi.report.model.bo.tally.*;
import com.ssy.lingxi.report.model.bo.tally.statistics.*;
import com.ssy.lingxi.report.model.vo.response.PurchaseTallyReportVO;
import com.ssy.lingxi.report.model.vo.response.TallyReportItemVO;
import com.ssy.lingxi.report.service.tally.IPurchaseTallyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 *  采购计数接口实现
 * @author ds
 * @date 2021/5/14
 * @version 2.0.0
 */
@Service
public class PurchaseTallyServiceImpl implements IPurchaseTallyService {

    private static final Logger logger = LoggerFactory.getLogger(PurchaseTallyServiceImpl.class);

    @Resource
    private PurchaseInquiryDAO purchaseInquiryDAO;
    @Resource
    private QuotedPriceDAO quotedPriceDAO;
    @Resource
    private BiddingDAO biddingDAO;
    @Resource
    private InviteTenderDAO inviteTenderDAO;
    @Resource
    private SubmitTenderDAO submitTenderDAO;
    @Resource
    private NeedPlanDAO needPlanDAO;
    @Resource
    private PurchasePlanDAO purchasePlanDAO;
    /**
     * 转换售后
     * @param reportBO 计数报表
     * @return 售后计数报表
     */
    @Override
    public PurchaseTallyReportVO convertPurchaseTally(MemberTallyReportBO reportBO) {
        PurchaseTallyReportVO result = new PurchaseTallyReportVO();
        // 转换采购询价数据
        result.setPurchaseInquiryList(convertPurchaseInquiryTally(reportBO.getPurchaseInquiry()));
        // 转换报价数据
        result.setQuotedPriceList(convertQuotedPriceTally(reportBO.getPurchaseQuotedPrice()));
        // 转换确认报价数据
        result.setConfirmQuotedPriceList(convertConfirmQuotedPriceTally(reportBO.getPurchaseConfirmQuotedPrice()));

        // 转换竞价数据
        result.setBiddingList(convertBiddingTally(reportBO.getPurchaseBidding()));

        // 转换在线竞价数据
        result.setOnlineBiddingList(convertOnlineBiddingTally(reportBO.getPurchaseOnlineBidding()));

        // 转换招标数据
        result.setInviteTenderList(convertInviteTenderTally(reportBO.getPurchaseInviteTender()));

        // 转换投标数据
        result.setTenderList(convertTenderTally(reportBO.getPurchaseTender()));

        // 转换需求计划数据
        result.setNeedPlanList(convertNeedPlanTally(reportBO.getPurchaseNeedPlan()));

        // 转换采购计划数据
        result.setPurchasePlanList(convertPurchasePlanTally(reportBO.getPurchasePlan()));

        return result;
    }

    /**
     * 转换平台采购
     * @param tallyBO
     * @return
     */
    public PurchaseTallyReportVO convertPlatformPurchaseTally(PlatformPurchaseTallyBO tallyBO) {
        PurchaseTallyReportVO vo=new PurchaseTallyReportVO();
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PlatformPurchaseTallyBO();
        }
        //待审核采购询价 22.1.20版本去掉
        TallyReportItemVO tallyReportItem;
  /*      tallyReportItem.setCount(tallyBO.getToBeVerifyInquiryCount() > 0 ? tallyBO.getToBeVerifyInquiryCount() : 0);
        tallyReportItem.setName(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_INQUIRY_COUNT.getName());
        tallyReportItem.setLink(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_INQUIRY_COUNT.getLink());
        resultList.add(tallyReportItem);*/
        //待审核采购竞价
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeVerifyBiddingCount() > 0 ? tallyBO.getToBeVerifyBiddingCount() : 0);
        tallyReportItem.setName(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_BIDDING_COUNT.getName());
        tallyReportItem.setLink(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_BIDDING_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核招标项目
/*        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeVerifyInviteTenderCount() > 0 ? tallyBO.getToBeVerifyInviteTenderCount() : 0);
        tallyReportItem.setName(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_INVITE_TENDER_COUNT.getName());
        tallyReportItem.setLink(PlatformPurchaseOperateTypeEnum.TO_BE_VERIFY_INVITE_TENDER_COUNT.getLink());
        resultList.add(tallyReportItem);*/
        vo.setPlatformPurchaseList(resultList);
        return vo;
    }

    /**
     * 转换采购询价数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertPurchaseInquiryTally(PurchaseInquiryTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseInquiryTallyBO();
        }

        // 待提交审核采购需求单
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseInquiryOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseInquiryOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待审核采购需求单（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseInquiryOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseInquiryOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待审核采购需求单（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseInquiryOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseInquiryOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        // 待提交采购需求单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseInquiryOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseInquiryOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换报价数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertQuotedPriceTally(PurchaseQuotedPriceTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseQuotedPriceTallyBO();
        }

        //待提交审核报价单
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseQuotedPriceOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseQuotedPriceOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核报价单（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核报价单（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交报价单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseQuotedPriceOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseQuotedPriceOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;

    }

    /**
     * 转换确认报价数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertConfirmQuotedPriceTally(PurchaseConfirmQuotedPriceTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseConfirmQuotedPriceTallyBO();
        }

        //待比价
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeContrastPriceCount() > 0 ? tallyBO.getToBeContrastPriceCount() : 0);
        tallyReportItem.setName(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_CONTRAST_PRICE_COUNT.getName());
        tallyReportItem.setLink(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_CONTRAST_PRICE_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核授标结果（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核授标结果（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待确认授标结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmCount() > 0 ? tallyBO.getToBeConfirmCount() : 0);
        tallyReportItem.setName(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_CONFIRM_COUNT.getName());
        tallyReportItem.setLink(PurchaseConfirmQuotedPriceOperateTypeEnum.TO_BE_CONFIRM_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换竞价数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertBiddingTally(PurchaseBiddingTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseBiddingTallyBO();
        }
        //待提交审核采购竞价单
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核采购竞价单（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核采购竞价单（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交采购竞价单
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核竞价报名
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyCount() > 0 ? tallyBO.getToBeValifyCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待竞价
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeBiddingCount() > 0 ? tallyBO.getToBeBiddingCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_BIDDING_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_BIDDING_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交审核竞价结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyResultCount() > 0 ? tallyBO.getToBeCommitValifyResultCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_VALIFY_RESULT_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_COMMIT_VALIFY_RESULT_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核竞价结果（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyResultStep1Count() > 0 ? tallyBO.getToBeValifyResultStep1Count() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_RESULT_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_RESULT_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核竞价结果（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyResultStep2Count() > 0 ? tallyBO.getToBeValifyResultStep2Count() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_RESULT_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_VALIFY_RESULT_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待确认竞价结果
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmResultCount() > 0 ? tallyBO.getToBeConfirmResultCount() : 0);
        tallyReportItem.setName(PurchaseBiddingOperateTypeEnum.TO_BE_CONFIRM_RESULT_COUNT.getName());
        tallyReportItem.setLink(PurchaseBiddingOperateTypeEnum.TO_BE_CONFIRM_RESULT_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换在线竞价数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertOnlineBiddingTally(PurchaseOnlineBiddingTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseOnlineBiddingTallyBO();
        }
        //待竞价报名
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeBiddingSignupCount() > 0 ? tallyBO.getToBeBiddingSignupCount() : 0);
        tallyReportItem.setName(PurchaseOnlineBiddingOperateTypeEnum.TO_BE_BIDDING_SIGNUP_COUNT.getName());
        tallyReportItem.setLink(PurchaseOnlineBiddingOperateTypeEnum.TO_BE_BIDDING_SIGNUP_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待竞价
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeBiddingCount() > 0 ? tallyBO.getToBeBiddingCount() : 0);
        tallyReportItem.setName(PurchaseOnlineBiddingOperateTypeEnum.TO_BE_BIDDING_COUNT.getName());
        tallyReportItem.setLink(PurchaseOnlineBiddingOperateTypeEnum.TO_BE_BIDDING_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换招标数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertInviteTenderTally(PurchaseInviteTenderTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseInviteTenderTallyBO();
        }
        //待提交审核招标
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核招标（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核招标（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交招标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核报名
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifySignupCount() > 0 ? tallyBO.getToBeValifySignupCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_SIGNUP_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_VALIFY_SIGNUP_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待资格预审.
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeQualificationValifyCount() > 0 ? tallyBO.getToBeQualificationValifyCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_QUALIFICATION_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_QUALIFICATION_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待专家评标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeExpertEvaluationCount() > 0 ? tallyBO.getToBeExpertEvaluationCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_EXPERT_EVALUATION_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_EXPERT_EVALUATION_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交评标报告
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitEvaluationCount() > 0 ? tallyBO.getToBeCommitEvaluationCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_EVALUATION_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_COMMIT_EVALUATION_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待定标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAppointCount() > 0 ? tallyBO.getToBeAppointCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核定标（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAppointStep1Count() > 0 ? tallyBO.getToBeAppointStep1Count() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核定标（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeAppointStep2Count() > 0 ? tallyBO.getToBeAppointStep2Count() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_APPOINT_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待确认定标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeConfirmAppointCount() > 0 ? tallyBO.getToBeConfirmAppointCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_CONFIRM_APPOINT_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_CONFIRM_APPOINT_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待中标公示
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeWinTenderPublishCount() > 0 ? tallyBO.getToBeWinTenderPublishCount() : 0);
        tallyReportItem.setName(PurchaseInviteTenderOperateTypeEnum.TO_BE_WIN_TENDER_PUBLISH_COUNT.getName());
        tallyReportItem.setLink(PurchaseInviteTenderOperateTypeEnum.TO_BE_WIN_TENDER_PUBLISH_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换投标数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertTenderTally(PurchaseTenderTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseTenderTallyBO();
        }
        //待招标报名
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeSignupCount() > 0 ? tallyBO.getToBeSignupCount() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_SIGNUP_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_SIGNUP_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交资格预审
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitQualificationCount() > 0 ? tallyBO.getToBeCommitQualificationCount() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_QUALIFICATION_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_QUALIFICATION_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交审核投标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核投标（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核投标（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交投标
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseTenderOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换需求计划数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertNeedPlanTally(PurchaseNeedPlanTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchaseNeedPlanTallyBO();
        }
        //待提交审核需求计划
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchaseNeedPlanOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchaseNeedPlanOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核需求计划（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchaseNeedPlanOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchaseNeedPlanOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核需求计划（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchaseNeedPlanOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchaseNeedPlanOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交需求计划
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitCount() > 0 ? tallyBO.getToBeCommitCount() : 0);
        tallyReportItem.setName(PurchaseNeedPlanOperateTypeEnum.TO_BE_COMMIT_COUNT.getName());
        tallyReportItem.setLink(PurchaseNeedPlanOperateTypeEnum.TO_BE_COMMIT_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 转换采购计划数据
     * @param tallyBO
     * @return
     */
    private List<TallyReportItemVO> convertPurchasePlanTally(PurchasePlanTallyBO tallyBO) {
        List<TallyReportItemVO> resultList = new ArrayList<>();
        if (tallyBO == null) {
            tallyBO = new PurchasePlanTallyBO();
        }
        //待汇总需求计划
        TallyReportItemVO tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeSummaryCount() > 0 ? tallyBO.getToBeSummaryCount() : 0);
        tallyReportItem.setName(PurchasePlanOperateTypeEnum.TO_BE_SUMMARY_COUNT.getName());
        tallyReportItem.setLink(PurchasePlanOperateTypeEnum.TO_BE_SUMMARY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待提交采购计划
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeCommitValifyCount() > 0 ? tallyBO.getToBeCommitValifyCount() : 0);
        tallyReportItem.setName(PurchasePlanOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getName());
        tallyReportItem.setLink(PurchasePlanOperateTypeEnum.TO_BE_COMMIT_VALIFY_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核采购计划（一级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep1Count() > 0 ? tallyBO.getToBeValifyStep1Count() : 0);
        tallyReportItem.setName(PurchasePlanOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getName());
        tallyReportItem.setLink(PurchasePlanOperateTypeEnum.TO_BE_VALIFY_STEP1_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待审核采购计划（二级）
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeValifyStep2Count() > 0 ? tallyBO.getToBeValifyStep2Count() : 0);
        tallyReportItem.setName(PurchasePlanOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getName());
        tallyReportItem.setLink(PurchasePlanOperateTypeEnum.TO_BE_VALIFY_STEP2_COUNT.getLink());
        resultList.add(tallyReportItem);
        //待执行采购计划
        tallyReportItem = new TallyReportItemVO();
        tallyReportItem.setCount(tallyBO.getToBeExecuteCount() > 0 ? tallyBO.getToBeExecuteCount() : 0);
        tallyReportItem.setName(PurchasePlanOperateTypeEnum.TO_BE_EXECUTE_COUNT.getName());
        tallyReportItem.setLink(PurchasePlanOperateTypeEnum.TO_BE_EXECUTE_COUNT.getLink());
        resultList.add(tallyReportItem);
        return resultList;
    }

    /**
     * 设置采购
     * @param tallyReportBO 会员计数报表
     * @param noticeVO 操作通知VO
     * @return 会员计数报表
     */
    @Override
    public MemberTallyReportBO setPurchaseTally(MemberTallyReportBO tallyReportBO, OperateNoticeVO noticeVO) {

        OperateDataSourceEnum sourceEnum = OperateDataSourceEnum.getEnum(noticeVO.getDataSource());
        switch (sourceEnum) {
            case PURCHASE_INQUIRY: // 转换采购询价数据
                tallyReportBO.setPurchaseInquiry(setPurchaseInquiryTally(tallyReportBO.getPurchaseInquiry(), noticeVO));
                break;
            case PURCHASE_QUOTED_PRICE: // 转换报价数据
                tallyReportBO.setPurchaseQuotedPrice(setPurchaseQuotedPriceTally(tallyReportBO.getPurchaseQuotedPrice(), noticeVO));
                break;
            case PURCHASE_CONFIRM_QUOTED_PRICE: // 转换确认报价数据
                tallyReportBO.setPurchaseConfirmQuotedPrice(setPurchaseConfirmQuotedPriceTally(tallyReportBO.getPurchaseConfirmQuotedPrice(), noticeVO));
                break;
            case PURCHASE_BIDDING: // 采购竞价
                tallyReportBO.setPurchaseBidding(setPurchaseBiddingTally(tallyReportBO.getPurchaseBidding(), noticeVO));
                break;
            case PURCHASE_ONLINE_BIDDING: // 转换在线竞价数据
                tallyReportBO.setPurchaseOnlineBidding(setPurchaseOnlineBiddingTally(tallyReportBO.getPurchaseOnlineBidding(), noticeVO));
                break;
            case PURCHASE_INVITE_TENDER: // 转换招标数据
                tallyReportBO.setPurchaseInviteTender(setPurchaseInviteTenderTally(tallyReportBO.getPurchaseInviteTender(), noticeVO));
                break;
            case PURCHASE_TENDER: // 转换投标数据
                tallyReportBO.setPurchaseTender(setPurchaseTenderTally(tallyReportBO.getPurchaseTender(), noticeVO));
                break;
            case PURCHASE_NEED_PLAN: // 转换需求计划数据
                tallyReportBO.setPurchaseNeedPlan(setPurchaseNeedPlanTally(tallyReportBO.getPurchaseNeedPlan(), noticeVO));
                break;
            case PURCHASE_PLAN: // 转换采购计划数据
                tallyReportBO.setPurchasePlan(setPurchasePlanTally(tallyReportBO.getPurchasePlan(), noticeVO));
                break;
            case PLATFORM_PURCHASE: // 转换平台采购统计数据
                tallyReportBO.setPlatformPurchase(setPlatformPurchaseTally(tallyReportBO.getPlatformPurchase(), noticeVO));
                break;
        }
        return tallyReportBO;
    }

    private PurchaseInquiryTallyBO setPurchaseInquiryTally(PurchaseInquiryTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseInquiryTallyBO();
        }
        // 更新数据
        PurchaseInquiryOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseInquiryOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseInquiryOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseQuotedPriceTallyBO setPurchaseQuotedPriceTally(PurchaseQuotedPriceTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseQuotedPriceTallyBO();
        }
        // 更新数据
        PurchaseQuotedPriceOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseQuotedPriceOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseQuotedPriceOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseConfirmQuotedPriceTallyBO setPurchaseConfirmQuotedPriceTally(PurchaseConfirmQuotedPriceTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseConfirmQuotedPriceTallyBO();
        }
        // 更新数据
        PurchaseConfirmQuotedPriceOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseConfirmQuotedPriceOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONTRAST_PRICE_COUNT:
                        tallyBO.setToBeContrastPriceCount(tallyBO.getToBeContrastPriceCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_COUNT:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseConfirmQuotedPriceOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_CONTRAST_PRICE_COUNT:
                        tallyBO.setToBeContrastPriceCount(tallyBO.getToBeContrastPriceCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_COUNT:
                        tallyBO.setToBeConfirmCount(tallyBO.getToBeConfirmCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseBiddingTallyBO setPurchaseBiddingTally(PurchaseBiddingTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseBiddingTallyBO();
        }
        // 更新数据
        PurchaseBiddingOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseBiddingOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_COUNT:
                        tallyBO.setToBeValifyCount(tallyBO.getToBeValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_BIDDING_COUNT:
                        tallyBO.setToBeBiddingCount(tallyBO.getToBeBiddingCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_RESULT_COUNT:
                        tallyBO.setToBeCommitValifyResultCount(tallyBO.getToBeCommitValifyResultCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_RESULT_STEP1_COUNT:
                        tallyBO.setToBeValifyResultStep1Count(tallyBO.getToBeValifyResultStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_RESULT_STEP2_COUNT:
                        tallyBO.setToBeValifyResultStep2Count(tallyBO.getToBeValifyResultStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_RESULT_COUNT:
                        tallyBO.setToBeConfirmResultCount(tallyBO.getToBeConfirmResultCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseBiddingOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_COUNT:
                        tallyBO.setToBeValifyCount(tallyBO.getToBeValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_BIDDING_COUNT:
                        tallyBO.setToBeBiddingCount(tallyBO.getToBeBiddingCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_RESULT_COUNT:
                        tallyBO.setToBeCommitValifyResultCount(tallyBO.getToBeCommitValifyResultCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_RESULT_STEP1_COUNT:
                        tallyBO.setToBeValifyResultStep1Count(tallyBO.getToBeValifyResultStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_RESULT_STEP2_COUNT:
                        tallyBO.setToBeValifyResultStep2Count(tallyBO.getToBeValifyResultStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_RESULT_COUNT:
                        tallyBO.setToBeConfirmResultCount(tallyBO.getToBeConfirmResultCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;

    }

    private PurchaseOnlineBiddingTallyBO setPurchaseOnlineBiddingTally(PurchaseOnlineBiddingTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseOnlineBiddingTallyBO();
        }
        // 更新数据
        PurchaseOnlineBiddingOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseOnlineBiddingOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_BIDDING_SIGNUP_COUNT:
                        tallyBO.setToBeBiddingSignupCount(tallyBO.getToBeBiddingSignupCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_BIDDING_COUNT:
                        tallyBO.setToBeBiddingCount(tallyBO.getToBeBiddingCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseOnlineBiddingOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_BIDDING_SIGNUP_COUNT:
                        tallyBO.setToBeBiddingSignupCount(tallyBO.getToBeBiddingSignupCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_BIDDING_COUNT:
                        tallyBO.setToBeBiddingCount(tallyBO.getToBeBiddingCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseInviteTenderTallyBO setPurchaseInviteTenderTally(PurchaseInviteTenderTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseInviteTenderTallyBO();
        }
        // 更新数据
        PurchaseInviteTenderOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseInviteTenderOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_SIGNUP_COUNT:
                        tallyBO.setToBeValifySignupCount(tallyBO.getToBeValifySignupCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_QUALIFICATION_VALIFY_COUNT:
                        tallyBO.setToBeQualificationValifyCount(tallyBO.getToBeQualificationValifyCount() - noticeVO.getReduceCount());
                        break;

                    case TO_BE_EXPERT_EVALUATION_COUNT:
                        tallyBO.setToBeExpertEvaluationCount(tallyBO.getToBeExpertEvaluationCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_EVALUATION_COUNT:
                        tallyBO.setToBeCommitEvaluationCount(tallyBO.getToBeCommitEvaluationCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_APPOINT_COUNT:
                        tallyBO.setToBeAppointCount(tallyBO.getToBeAppointCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_APPOINT_STEP1_COUNT:
                        tallyBO.setToBeAppointStep1Count(tallyBO.getToBeAppointStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_APPOINT_STEP2_COUNT:
                        tallyBO.setToBeAppointStep2Count(tallyBO.getToBeAppointStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_CONFIRM_APPOINT_COUNT:
                        tallyBO.setToBeConfirmAppointCount(tallyBO.getToBeConfirmAppointCount() - noticeVO.getReduceCount());
                        break;

                    case TO_BE_WIN_TENDER_PUBLISH_COUNT:
                        tallyBO.setToBeWinTenderPublishCount(tallyBO.getToBeWinTenderPublishCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseInviteTenderOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_SIGNUP_COUNT:
                        tallyBO.setToBeValifySignupCount(tallyBO.getToBeValifySignupCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_QUALIFICATION_VALIFY_COUNT:
                        tallyBO.setToBeQualificationValifyCount(tallyBO.getToBeQualificationValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_EXPERT_EVALUATION_COUNT:
                        tallyBO.setToBeExpertEvaluationCount(tallyBO.getToBeExpertEvaluationCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_EVALUATION_COUNT:
                        tallyBO.setToBeCommitEvaluationCount(tallyBO.getToBeCommitEvaluationCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_APPOINT_COUNT:
                        tallyBO.setToBeAppointCount(tallyBO.getToBeAppointCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_APPOINT_STEP1_COUNT:
                        tallyBO.setToBeAppointStep1Count(tallyBO.getToBeAppointStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_APPOINT_STEP2_COUNT:
                        tallyBO.setToBeAppointStep2Count(tallyBO.getToBeAppointStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_CONFIRM_APPOINT_COUNT:
                        tallyBO.setToBeConfirmAppointCount(tallyBO.getToBeConfirmAppointCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_WIN_TENDER_PUBLISH_COUNT:
                        tallyBO.setToBeWinTenderPublishCount(tallyBO.getToBeWinTenderPublishCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseTenderTallyBO setPurchaseTenderTally(PurchaseTenderTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseTenderTallyBO();
        }
        // 更新数据
        PurchaseTenderOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseTenderOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SIGNUP_COUNT:
                        tallyBO.setToBeSignupCount(tallyBO.getToBeSignupCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_QUALIFICATION_COUNT:
                        tallyBO.setToBeCommitQualificationCount(tallyBO.getToBeCommitQualificationCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseTenderOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SIGNUP_COUNT:
                        tallyBO.setToBeSignupCount(tallyBO.getToBeSignupCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_QUALIFICATION_COUNT:
                        tallyBO.setToBeCommitQualificationCount(tallyBO.getToBeCommitQualificationCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    private PurchaseNeedPlanTallyBO setPurchaseNeedPlanTally(PurchaseNeedPlanTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchaseNeedPlanTallyBO();
        }
        // 更新数据
        PurchaseNeedPlanOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchaseNeedPlanOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchaseNeedPlanOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_COUNT:
                        tallyBO.setToBeCommitCount(tallyBO.getToBeCommitCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    /**
     * 设置采购计划数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private PurchasePlanTallyBO setPurchasePlanTally(PurchasePlanTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PurchasePlanTallyBO();
        }
        // 更新数据
        PurchasePlanOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PurchasePlanOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SUMMARY_COUNT:
                        tallyBO.setToBeSummaryCount(tallyBO.getToBeSummaryCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() - noticeVO.getReduceCount());
                        break;
                    case TO_BE_EXECUTE_COUNT:
                        tallyBO.setToBeExecuteCount(tallyBO.getToBeExecuteCount() - noticeVO.getReduceCount());
                        break;
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PurchasePlanOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                    case TO_BE_SUMMARY_COUNT:
                        tallyBO.setToBeSummaryCount(tallyBO.getToBeSummaryCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_COMMIT_VALIFY_COUNT:
                        tallyBO.setToBeCommitValifyCount(tallyBO.getToBeCommitValifyCount() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP1_COUNT:
                        tallyBO.setToBeValifyStep1Count(tallyBO.getToBeValifyStep1Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_VALIFY_STEP2_COUNT:
                        tallyBO.setToBeValifyStep2Count(tallyBO.getToBeValifyStep2Count() + noticeVO.getIncreaseCount());
                        break;
                    case TO_BE_EXECUTE_COUNT:
                        tallyBO.setToBeExecuteCount(tallyBO.getToBeExecuteCount() + noticeVO.getIncreaseCount());
                        break;
                }
            }
        }
        return tallyBO;
    }

    /**
     * 设置平台采购统计数据
     * @param tallyBO
     * @param noticeVO
     * @return
     */
    private PlatformPurchaseTallyBO setPlatformPurchaseTally(PlatformPurchaseTallyBO tallyBO, OperateNoticeVO noticeVO) {
        if (tallyBO == null) {
            tallyBO = new PlatformPurchaseTallyBO();
        }
        // 更新数据
        PlatformPurchaseOperateTypeEnum typeEnum;
        if (noticeVO.getReduceCount() > 0) {
            typeEnum = PlatformPurchaseOperateTypeEnum.getEnum(noticeVO.getReduceOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                   /* case TO_BE_VERIFY_INQUIRY_COUNT: //22.1.20版本去掉
                        tallyBO.setToBeVerifyInquiryCount(tallyBO.getToBeVerifyInquiryCount() - noticeVO.getReduceCount());
                        break;*/
                    case TO_BE_VERIFY_BIDDING_COUNT:
                        tallyBO.setToBeVerifyBiddingCount(tallyBO.getToBeVerifyBiddingCount() - noticeVO.getReduceCount());
                        break;
                   /* case TO_BE_VERIFY_INVITE_TENDER_COUNT: //22.1.20版本去掉
                        tallyBO.setToBeVerifyInviteTenderCount(tallyBO.getToBeVerifyInviteTenderCount() - noticeVO.getReduceCount());
                        break;*/
                }
            }
        }
        if (noticeVO.getIncreaseCount() > 0) {
            typeEnum = PlatformPurchaseOperateTypeEnum.getEnum(noticeVO.getIncreaseOperateType());
            if (typeEnum != null) {
                switch (typeEnum) {
                   /* case TO_BE_VERIFY_INQUIRY_COUNT: //22.1.20版本去掉
                        tallyBO.setToBeVerifyInquiryCount(tallyBO.getToBeVerifyInquiryCount() + noticeVO.getIncreaseCount());
                        break;*/
                    case TO_BE_VERIFY_BIDDING_COUNT:
                        tallyBO.setToBeVerifyBiddingCount(tallyBO.getToBeVerifyBiddingCount() + noticeVO.getIncreaseCount());
                        break;
             /*       case TO_BE_VERIFY_INVITE_TENDER_COUNT: //22.1.20版本去掉
                        tallyBO.setToBeVerifyInviteTenderCount(tallyBO.getToBeVerifyInviteTenderCount() + noticeVO.getIncreaseCount());
                        break;*/
                }
            }
        }
        return tallyBO;
    }

    /**
     * 统计计数-采购
     * @param reportList
     * @return
     */
    @Override
    public List<MemberTallyReportDO> statisticsTally(List<MemberTallyReportDO> reportList) {
        //采购询价
        reportList = statisticsPurchaseInquiryTally(reportList);
        //报价
        reportList = statisticsQuotedPriceTally(reportList);
        //确认报价
        reportList = statisticsConfirmQuotedPriceTally(reportList);
        //采购竞价
        reportList = statisticsBiddingTally(reportList);
        //在线竞价
        reportList = statisticsOnlineBiddingTally(reportList);
        //招标
        reportList = statisticsInviteTenderTally(reportList);
        //投标
        reportList = statisticsTenderTally(reportList);
        //需求计划
        reportList = statisticsNeedPlanTally(reportList);
        //采购计划
        reportList = statisticsPurchasePlanTally(reportList);
        //统计平台采购
        reportList=statisticsPlatformPurchaseTally(reportList);
        return reportList;
    }

    /**
     * 统计采购询价
     * @param reportList 会员计数报表
     * @return 会员计数报表
     */
    private List<MemberTallyReportDO> statisticsPurchaseInquiryTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseInquiryStatisticsTallyVO> statusStatisticsCount = purchaseInquiryDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseInquiryTallyBO bo=new PurchaseInquiryTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseInquiry(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseInquiryTallyBO contractMange = memberTallyReportDO.getTallyReport().getPurchaseInquiry();
                    if(contractMange==null){
                        contractMange=new PurchaseInquiryTallyBO();
                        BeanUtils.copyProperties(o,contractMange);
                    }
                    BeanUtils.copyProperties(o,contractMange);
                    memberTallyReportDO.getTallyReport().setPurchaseInquiry(contractMange);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计采购报价
     * @param reportList 会员计数报表
     * @return 会员计数报表
     */
    private List<MemberTallyReportDO> statisticsQuotedPriceTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseQuotedPriceStatisticsTallyVO> statusStatisticsCount = quotedPriceDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseQuotedPriceTallyBO bo=new PurchaseQuotedPriceTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseQuotedPrice(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseQuotedPriceTallyBO quotedPrice = memberTallyReportDO.getTallyReport().getPurchaseQuotedPrice();
                    if(quotedPrice==null){
                        quotedPrice=new PurchaseQuotedPriceTallyBO();
                    }
                    BeanUtils.copyProperties(o,quotedPrice);
                    memberTallyReportDO.getTallyReport().setPurchaseQuotedPrice(quotedPrice);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计采购确认报价
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsConfirmQuotedPriceTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseConfirmQuotedPriceStatisticsTallyVO> statusStatisticsCount = purchaseInquiryDAO.getConfirmQuotedPriceStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseConfirmQuotedPriceTallyBO bo=new PurchaseConfirmQuotedPriceTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseConfirmQuotedPrice(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseConfirmQuotedPriceTallyBO confirmQuotedPrice = memberTallyReportDO.getTallyReport().getPurchaseConfirmQuotedPrice();
                    if(confirmQuotedPrice==null){
                        confirmQuotedPrice=new PurchaseConfirmQuotedPriceTallyBO();
                    }
                    BeanUtils.copyProperties(o,confirmQuotedPrice);
                    memberTallyReportDO.getTallyReport().setPurchaseConfirmQuotedPrice(confirmQuotedPrice);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计采购竞价
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsBiddingTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseBiddingStatisticsTallyVO> statusStatisticsCount = biddingDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseBiddingTallyBO bo=new PurchaseBiddingTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseBidding(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseBiddingTallyBO confirmQuotedPrice = memberTallyReportDO.getTallyReport().getPurchaseBidding();
                    if(confirmQuotedPrice==null){
                        confirmQuotedPrice=new PurchaseBiddingTallyBO();
                    }
                    BeanUtils.copyProperties(o,confirmQuotedPrice);
                    memberTallyReportDO.getTallyReport().setPurchaseBidding(confirmQuotedPrice);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计在线竞价
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsOnlineBiddingTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseOnlineBiddingStatisticsTallyVO> statusStatisticsCount = biddingDAO.getOnlineStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseOnlineBiddingTallyBO bo=new PurchaseOnlineBiddingTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseOnlineBidding(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseOnlineBiddingTallyBO confirmQuotedPrice = memberTallyReportDO.getTallyReport().getPurchaseOnlineBidding();
                    if(confirmQuotedPrice==null){
                        confirmQuotedPrice=new PurchaseOnlineBiddingTallyBO();
                    }
                    BeanUtils.copyProperties(o,confirmQuotedPrice);
                    memberTallyReportDO.getTallyReport().setPurchaseOnlineBidding(confirmQuotedPrice);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 招标统计
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsInviteTenderTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseInviteTenderStatisticsTallyVO> statusStatisticsCount = inviteTenderDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseInviteTenderTallyBO bo=new PurchaseInviteTenderTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseInviteTender(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseInviteTenderTallyBO bo = memberTallyReportDO.getTallyReport().getPurchaseInviteTender();
                    if(bo==null){
                        bo=new PurchaseInviteTenderTallyBO();
                    }
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseInviteTender(bo);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 投标统计
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsTenderTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseSubmitTenderStatisticsTallyVO> statusStatisticsCount = submitTenderDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseTenderTallyBO bo=new PurchaseTenderTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseTender(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseTenderTallyBO bo = memberTallyReportDO.getTallyReport().getPurchaseTender();
                    if(bo==null){
                        bo=new PurchaseTenderTallyBO();
                    }
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseTender(bo);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计需求计划
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsNeedPlanTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchaseNeedPlanStatisticsTallyVO> statusStatisticsCount = needPlanDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchaseNeedPlanTallyBO bo=new PurchaseNeedPlanTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseNeedPlan(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchaseNeedPlanTallyBO bo = memberTallyReportDO.getTallyReport().getPurchaseNeedPlan();
                    if(bo==null){
                        bo=new PurchaseNeedPlanTallyBO();
                    }
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchaseNeedPlan(bo);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 统计采购计划
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsPurchasePlanTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        List<PurchasePlanStatisticsTallyVO> statusStatisticsCount = purchasePlanDAO.getStatisticsCount();
        if(CollectionUtil.isNotEmpty(statusStatisticsCount)){
            statusStatisticsCount.forEach(o ->{
                String key=o.getMemberId()+":"+o.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(o.getMemberId());
                    memberTallyReportDO.setRoleId(o.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PurchasePlanTallyBO bo=new PurchasePlanTallyBO();
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchasePlan(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PurchasePlanTallyBO bo = memberTallyReportDO.getTallyReport().getPurchasePlan();
                    if(bo==null){
                        bo=new PurchasePlanTallyBO();
                    }
                    BeanUtils.copyProperties(o,bo);
                    memberTallyReportDO.getTallyReport().setPurchasePlan(bo);
                }
            });
        }
        return new ArrayList<>(dbReportList.values());
    }
    /**
     * 统计平台采购
     * @param reportList
     * @return
     */
    private List<MemberTallyReportDO> statisticsPlatformPurchaseTally(List<MemberTallyReportDO> reportList) {
        if (reportList == null) {
            reportList = new ArrayList<>();
        }
        Map<String, MemberTallyReportDO> dbReportList = reportList.stream().collect(Collectors.toMap(o -> o.getMemberId() + ":" + o.getRoleId(), o -> o));

        PlatformPurchaseStatisticsTallyVO platformPurchaseCount = getPlatformPurchaseStatistics();
                String key=platformPurchaseCount.getMemberId()+":"+platformPurchaseCount.getRoleId();
                MemberTallyReportDO memberTallyReportDO = dbReportList.get(key);
                if(memberTallyReportDO==null){
                    memberTallyReportDO=new MemberTallyReportDO();
                    memberTallyReportDO.setMemberId(platformPurchaseCount.getMemberId());
                    memberTallyReportDO.setRoleId(platformPurchaseCount.getRoleId());
                    MemberTallyReportBO memberTallyReportBO=new MemberTallyReportBO();
                    memberTallyReportDO.setTallyReport(memberTallyReportBO);
                    PlatformPurchaseTallyBO bo=new PlatformPurchaseTallyBO();
                    BeanUtils.copyProperties(platformPurchaseCount,bo);
                    memberTallyReportDO.getTallyReport().setPlatformPurchase(bo);
                    dbReportList.put(key,memberTallyReportDO);
                }else{
                    PlatformPurchaseTallyBO bo = memberTallyReportDO.getTallyReport().getPlatformPurchase();
                    if(bo==null){
                        bo=new PlatformPurchaseTallyBO();
                    }
                    BeanUtils.copyProperties(platformPurchaseCount,bo);
                    memberTallyReportDO.getTallyReport().setPlatformPurchase(bo);
                }
        return new ArrayList<>(dbReportList.values());
    }

    /**
     * 获得采购-平台-待审核[询价、竞价、招标]计数
     * @return
     */
    private PlatformPurchaseStatisticsTallyVO getPlatformPurchaseStatistics(){
        PlatformPurchaseStatisticsTallyVO result=new PlatformPurchaseStatisticsTallyVO();
        result.setMemberId(MemberRoleEnum.PLATFORM.getMemberId());
        result.setRoleId(MemberRoleEnum.PLATFORM.getRoleId());
        PlatformPurchaseStatisticsTallyVO inquiryCount = purchaseInquiryDAO.getPlatformStatisticsCount();
        if(inquiryCount!=null){
            result.setToBeVerifyInquiryCount(inquiryCount.getToBeVerifyInquiryCount());
        }
        PlatformPurchaseStatisticsTallyVO biddingCount = biddingDAO.getPlatformStatisticsCount();
        if(biddingCount!=null){
            result.setToBeVerifyBiddingCount(biddingCount.getToBeVerifyBiddingCount());
        }
        PlatformPurchaseStatisticsTallyVO inviteTenderCount = inviteTenderDAO.getPlatformStatisticsCount();
        if(inviteTenderCount!=null){
            result.setToBeVerifyInviteTenderCount(inviteTenderCount.getToBeVerifyInviteTenderCount());
        }
        return result;
    }
}
